import { UserService } from '../../../../modules/user/user.service';
import { Module, forwardRef } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { HttpModule } from '@nestjs/axios';
import { TypeSchema } from '../../superType/types/schemas/type.schema';
import { LcDocumentBackupSchema, LcDocumentSchema, LcProjectSchema } from '../types/editor.schema';
import { EditorController } from './editor.controller';
import { EditorService } from './editor.service';
import { UserModule } from '../../../../modules/user/user.module';
import { SessionSchema } from '../../../../modules/shared/schema/session.schema';
import { AccessControlService } from './access-control.service';
import { AccessControlController } from './access-control.controller';
import { VersionControlModule } from './version-control.module';
import { ProjectExportService } from './project-export/project-export.service';
import { DataSourceModule } from '../../superType/server/data-source.module';
import { ProjectExportController } from './project-export/project-export.controller';
import { ResourceScannerService } from './project-export/services/resource-scanner.service';
import { ResourceDownloaderService } from './project-export/services/resource-downloader.service';
import { ResourceManifestService } from './project-export/services/resource-manifest.service';
import { MinioService } from './project-export/services/minio.service';
// 🆕 VFS相关导入
import { VFSModule } from './vfs/vfs.module';
import { ValidationModule } from './validation/validation.module';
import { CodeTransformerModule } from './code-transformer/code-transformer.module';
import { VFSService } from './vfs/vfs.service';
import { TypeModule } from '../../superType/server/type.module';

@Module({
  imports: [
    MongooseModule.forFeature([
      { name: 'project', schema: LcProjectSchema },
      { name: 'doc', schema: LcDocumentSchema },
      { name: 'doc_backup', schema: LcDocumentBackupSchema },
      { name: 'type', schema: TypeSchema },
      { name: 'session', schema: SessionSchema },
    ]),
    UserModule,
    HttpModule, // 🆕 添加HTTP模块用于编辑器通知
    // 🆕 版本控制模块
    VersionControlModule,
    // 🆕 数据源模块
    DataSourceModule,
    // 🆕 VFS相关模块
    VFSModule,
    ValidationModule,
    CodeTransformerModule,
    forwardRef(() => TypeModule), // 导入 TypeModule 以使用 TypeService
  ],
  providers: [
    EditorService,
    AccessControlService, // 🆕 访问控制服务
    ProjectExportService, // 🆕 项目导出导入服务
    ResourceScannerService, // 🆕 资源扫描服务
    ResourceDownloaderService, // 🆕 资源下载服务
    ResourceManifestService, // 🆕 资源清单服务
    VFSService,
    MinioService, // 🆕 Minio存储服务
  ],
  controllers: [
    EditorController,
    AccessControlController, // 🆕 访问控制控制器
    ProjectExportController, // 🆕 项目导出导入控制器
  ],
  exports: [
    EditorService,
    AccessControlService, // 🆕 导出访问控制服务
    ProjectExportService, // 🆕 导出项目导出导入服务
  ],
})
export class EditorModule {}
